package com.agricultural.strategy.impl;

import com.agricultural.equipment.AgriculturalEquipment;
import com.agricultural.strategy.PathPlanningStrategy;

import java.util.Map;

// 默认路径规划策略
public class DefaultPathStrategy implements PathPlanningStrategy {
    
    // 获取策略名称
    @Override
    public String getStrategyName() {
        return "默认路径规划策略";
    }
    
    // 规划路径
    @Override
    public void planPath(AgriculturalEquipment equipment, Map<String, Object> environmentData) {
        System.out.println("[" + equipment.getType() + "-" + equipment.getId() + "] 使用默认路径规划策略");
        
        // 模拟路径规划计算
        double currentX = equipment.getStatus().get("positionX") != null ? 
                          (double) equipment.getStatus().get("positionX") : 0.0;
        double currentY = equipment.getStatus().get("positionY") != null ? 
                          (double) equipment.getStatus().get("positionY") : 0.0;
        
        // 计算新位置（简单示例：沿X轴移动10个单位）
        double newX = currentX + 10.0;
        double newY = currentY;
        
        // 更新设备位置
        String newPosition = String.format("(%.2f, %.2f)", newX, newY);
        equipment.updateStatusData("position", newPosition);
        
        System.out.println("[" + equipment.getType() + "-" + equipment.getId() + "] 新路径规划完成: " + newPosition);
    }
}    